package com.gym.openapi.web.controller;

import com.gym.openapi.common.ResponseResult;
import com.gym.openapi.common.ResultTable;
import com.gym.openapi.entity.ApiMapping;
import com.gym.openapi.services.ApiMappingServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ming
 * 2021/11/26
 * description:路由管理
 */
@RestController
@RequestMapping("/api_mapping")
public class ApiMappingController {
    @Autowired
    private ApiMappingServices apiMappingServices;


    /**
     * @author:ming
     * @Date: 2021/11/27
     * @description:页面显示 搜索栏搜索
     */
    @RequestMapping("table")
    public ResultTable apiTable(@RequestParam(defaultValue = "1") Integer page,
                                @RequestParam(defaultValue = "10") Integer limit,
                                String gatewayApiName, Byte state) {
        return apiMappingServices.apiTable(page, limit, gatewayApiName, state);

    }

    /**
     * @author:ming
     * @Date: 2021/11/27
     * @description:批量删除
     */
    @RequestMapping("/del")
    public ResponseResult del(Integer[] ids) {
        return apiMappingServices.del(ids);
    }


    /**
     * @author:ming
     * @Date: 2021/11/27
     * @description:编辑修改信息
     */
    @RequestMapping("/update")
    public ResponseResult update(ApiMapping apiMapping) {
        return apiMappingServices.update(apiMapping);
    }

    /**
     * @author:ming
     * @Date: 2021/11/27
     * @description:添加数据
     */
    @RequestMapping("/add")
    public ResponseResult add(ApiMapping apiMapping) {
        return apiMappingServices.add(apiMapping);
    }
}
